diag[3]={0};
if(p==1){
if(x==y)
diag[x]++;
}
else
diag[x]--





My solution:

{{

#define SIZE 3
#define MSIZE -3

int row[SIZE];
int col[SIZE];

int init () {
int i, j;
for (i=0; i<SIZE; ++i)
row[i] = 0;
for (j=0; j<SIZE; ++j)
row[j] = 0;
}

// 0: no win
// 1: 1st player win
// 2: 2nd player win
int check (int x, int y, int p){ // O(1)
if (p == 1){
row[y]++;
col[x]++;
}
else {
col[x]--;
row[y]--;
}

if (row[y] == SIZE || 
row[y] == MSIZE ||
col[x] == SIZE ||
col[x] == MSIZE)
return p; // 

return 0;
}

}}


